-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Added option to build GPU libraries separately #4298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Added option to build GPU libraries separately #4298
Conversation
Current PR is based on 1.10 - should of course be rebased. |
It might make more sense to name the libraries |
Sorry, I didn't quite get this part:
Why can't the user just load the CUDA libfaiss_c if they are using GPU, i.e. skip the first step? |
The reason the user can't just load the CUDA libfaiss_c is a combination of:
In addition, the preferred method for adding CUDA functionality is via Julia package extensions, where the Faiss (Julia) package may be extended, at run-time, with additional functionality, e.g., CUDA. I.e., it should be enough to add the |
Hi @stemann sorry for the delay, was still discussing internally. But I see you have moved the PR to draft mode, so I will follow up after you publish again |
No worries. Please do comment on the general idea. I only moved the PR to draft as it is a bit of a rough draft. |
@stemann I am trying to see if making it just shared by default is workable and not having a static version, then we can just keep the 1 GPU flag instead of introducing a new one. If not, we can go with the approach in this PR. |
Ah - that sounds good. On a related note, I've also been toying around (also in JuliaPackaging/Yggdrasil#11057) with building the AVX2, and AVX512 versions, where it would actually be preferable to get a library with the same name, e.g. |
In some cases, it might be preferable to have GPU support as an optional add-on feature, e.g., in Julia. This PR adds a cmake option to enable the GPU library, and the GPU C library, to be built as separate shared libraries.
This enables a consumer to
dlopen
(libfaiss_c
, and)libfaiss
, and if, e.g., CUDA is available to also load the CUDA (libfaiss_gpu_c
, and)libfaiss_gpu
.With the current build set-up, where the GPU objects are statically linked into
libfaiss
, a consumer mightdlopen
the non-CUDAlibfaiss_c
, and in turn the non-CUDAlibfaiss
. Then when loading the CUDAlibfaiss_c
, the dynamic linker will re-use the non-CUDAlibfaiss
and fail to resolve CUDA/GPU symbols inlibfaiss
: